package com.hytc.service.impl;


import com.hytc.dao.UserDao;
import com.hytc.dao.impl.UserDaoImpl;
import com.hytc.entity.Cart;
import com.hytc.entity.Product;
import com.hytc.entity.User;
import com.hytc.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {
    private UserDao dao =  new UserDaoImpl();


    @Override
    public void registerUser(User user) {
        dao.saveUser(user);
    }

    @Override
    public User login(String username, String password) {
        return dao.queryByUsernameAndPassword(username, password);
    }

    @Override
    public boolean existsUsername(String username) {
        if (dao.queryByUsername(username) == null) {
            return false;
        }
        return true;
    }

    @Override
    public List<Product> query() {
        return dao.queryBycategory_id();
    }

    @Override
    public List<User> find() {
        return  dao.find();
    }

    @Override
    public List<Cart> cart(Long id) {
        return dao.cart(id);
    }


    @Override
    public boolean add(int id, Long user_id) {
        return dao.add(id,user_id);
    }

    @Override
    public boolean delete(int id, int user_id) {
        return dao.delete(id, user_id);
    }

    @Override
    public void addcart(Product product, String mount, Long id) {
        dao.addcart(product,mount,id);
    }

}
